workspace(name = "waymo_open_dataset_rules")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
    name = "rules_proto",
    sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
    strip_prefix = "rules_proto-5.3.0-21.7",
    urls = [
        "https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
    ],
)

http_archive(
    name = "rules_python",
    sha256 = "9d04041ac92a0985e344235f5d946f71ac543f1b1565f2cdbc9a2aaee8adf55b",
    strip_prefix = "rules_python-0.26.0",
    url = "https://github.com/bazelbuild/rules_python/releases/download/0.26.0/rules_python-0.26.0.tar.gz",
)
load("@rules_python//python:repositories.bzl", "py_repositories")
py_repositories()

http_archive(
    name = "rules_cc",
    urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"],
    sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf",
    strip_prefix = "rules_cc-0.0.9",
)

http_archive(
    name = "rules_license",
    sha256 = "6157e1e68378532d0241ecd15d3c45f6e5cfd98fc10846045509fb2a7cc9e381",
    urls = [
        "https://github.com/bazelbuild/rules_license/releases/download/0.0.4/rules_license-0.0.4.tar.gz",
        "https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/0.0.4/rules_license-0.0.4.tar.gz",
    ],
)

http_archive(
    name = "com_google_googletest",
    sha256 = "ff7a82736e158c077e76188232eac77913a15dac0b22508c390ab3f88e6d6d86",
    strip_prefix = "googletest-b6cd405286ed8635ece71c72f118e659f4ade3fb",
    urls = [
        "http://mirror.tensorflow.org/github.com/google/googletest/archive/b6cd405286ed8635ece71c72f118e659f4ade3fb.zip",
        "https://github.com/google/googletest/archive/b6cd405286ed8635ece71c72f118e659f4ade3fb.zip",
    ],
)

http_archive(
    name = "com_github_gflags_gflags",
    sha256 = "ae27cdbcd6a2f935baa78e4f21f675649271634c092b1be01469440495609d0e",
    strip_prefix = "gflags-2.2.1",
    urls = [
        "http://mirror.tensorflow.org/github.com/gflags/gflags/archive/v2.2.1.tar.gz",
        "https://github.com/gflags/gflags/archive/v2.2.1.tar.gz",
    ],
)

http_archive(
    name = "com_google_glog",
    build_file = "//waymo_open_dataset:bazel/glog.BUILD",
    sha256 = "375106b5976231b92e66879c1a92ce062923b9ae573c42b56ba28b112ee4cc11",
    strip_prefix = "glog-0.7.0",
    urls = [
        "https://github.com/google/glog/archive/refs/tags/v0.7.0.tar.gz",
    ],
)

http_archive(
    name = "boringssl",
    sha256 = "542dd328952cea08785b58990b12e0832c49123807c8854e136136830c8b115c",
    strip_prefix = "boringssl-da7997d97fa17f22cc3eb9c681c8494af7a98eef",
    urls = [
        "http://mirror.tensorflow.org/github.com/google/boringssl/archive/da7997d97fa17f22cc3eb9c681c8494af7a98eef.tar.gz",
        "https://github.com/google/boringssl/archive/da7997d97fa17f22cc3eb9c681c8494af7a98eef.tar.gz",
    ],
)

http_archive(
    name = "com_google_absl",
    sha256 = "9892836ab0d3f099b8c15076c6f4168144f452d097bd49da215fe0df36a2d48c",
    strip_prefix = "abseil-cpp-c2435f8342c2d0ed8101cb43adfd605fdc52dca2",
    urls = [
        "https://github.com/abseil/abseil-cpp/archive/c2435f8342c2d0ed8101cb43adfd605fdc52dca2.tar.gz"
    ],
)

http_archive(
    name = "zlib",
    build_file = "//waymo_open_dataset:bazel/zlib.BUILD",
    sha256 = "91844808532e5ce316b3c010929493c0244f3d37593afd6de04f71821d5136d9",
    strip_prefix = "zlib-1.2.12",
    urls = [
        "http://mirror.tensorflow.org/zlib.net/zlib-1.2.12.tar.gz",
        "https://zlib.net/zlib-1.2.12.tar.gz",
    ],
)

http_archive(
    name = "six_archive",
    build_file = "//waymo_open_dataset:bazel/six.BUILD",
    sha256 = "30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259",
    strip_prefix = "six-1.15.0",
    urls = [
        "https://storage.googleapis.com/mirror.tensorflow.org/pypi.python.org/packages/source/s/six/six-1.15.0.tar.gz",
        "https://pypi.python.org/packages/source/s/six/six-1.15.0.tar.gz",
    ],
)

bind(
    name = "six",
    actual = "@six_archive//:six",
)

http_archive(
    name = "bazel_skylib",
    sha256 = "b8a1527901774180afc798aeb28c4634bdccf19c4d98e7bdd1ce79d1fe9aaad7",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz",
        "https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.1/bazel-skylib-1.4.1.tar.gz",
    ],
)

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

http_archive(
    name = "com_google_protobuf",
    sha256 = "f66073dee0bc159157b0bd7f502d7d1ee0bc76b3c1eac9836927511bdc4b3fc1",
    strip_prefix = "protobuf-3.21.9",
    urls = [
        "https://github.com/protocolbuffers/protobuf/archive/v3.21.9.zip",
    ],
)
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
protobuf_deps()

http_archive(
    name = "deeplab2",
    build_file = "//waymo_open_dataset:bazel/deeplab2.BUILD",
    sha256 = "d5ce468a0ddb40cc7b22c71a82c26b506c95d55905a1c44ce1c87208f3a76b61",
    strip_prefix = "deeplab2-17c7ff3cadf4ee56b27b1cb73f1e15b69c5bd8a9",
    urls = [
        "https://github.com/google-research/deeplab2/archive/17c7ff3cadf4ee56b27b1cb73f1e15b69c5bd8a9.zip",
    ],
)

http_archive(
    name = "tflite_micro",
    sha256 = "d6aba330e299f1add8efc6b2bb53806fac82afb84a4f48f7bbe154e087adbe50",
    strip_prefix = "tflite-micro-380a6c125c4d699fa3f434e1429802ee825e739d",
    urls = [
        "https://github.com/tensorflow/tflite-micro/archive/380a6c125c4d699fa3f434e1429802ee825e739d.zip",
    ],
)

# We TensorFlow from the pip package via pip_parse below, this repo is only
# needed for bzl scripts (ex. tf_gen_op_wrapper_py), which are not in the pip
# package.
http_archive(
    name = "org_tensorflow",
    sha256 = "447cdb65c80c86d6c6cf1388684f157612392723eaea832e6392d219098b49de",
    strip_prefix = "tensorflow-2.13.0",
    urls = ["https://github.com/tensorflow/tensorflow/archive/v2.13.0.zip"],
)

###########################################
# Custom configuration of the workspace.
###########################################

load("@rules_python//python:repositories.bzl", "py_repositories", "python_register_toolchains")

py_repositories()

python_register_toolchains(
    name = "python3_10",
    python_version = "3.10",
    # Bazel's rules_python marks the python installation's lib directory as
    # read-only. This prevents python interpretor from generating .pyc files.
    # rules_python intend for that behavior because the content of .pyc files
    # are platform dependent. If .pyc files were included in a bazel action
    # inputs, then there would be erroneous cache misses. The problem is that
    # in linux docker containers root users can still write to read-only
    # directories, resulting in .pyc files, resulting in erroneous cache misses.
    # By default rules_python errors when running as a root user because people
    # don't want cache misses. But Colab runs as the root user.  So we need to
    # overide the check preventing root user. See
    # https://github.com/bazelbuild/rules_python/pull/713 for more details on
    # the root problem and this work around.
    ignore_root_user_error = True,
)

load("@python3_10//:defs.bzl", "interpreter")
load("@rules_python//python:pip.bzl", "pip_parse")

pip_parse(
    name = "wod_deps",
    python_interpreter_target = interpreter,
    quiet = False,
    requirements_lock = "//waymo_open_dataset:requirements.txt",
)

load("@wod_deps//:requirements.bzl", "install_deps", "requirement")

install_deps()

load("@tflite_micro//python:py_pkg_cc_deps.bzl", "py_pkg_cc_deps")

py_pkg_cc_deps(
    name = "tensorflow_cc_deps",
    includes = ["tensorflow/include"],
    libs = ["tensorflow/libtensorflow_framework.so.2"],
    pkg = requirement("tensorflow"),
)
